"""
参考：
    使用 SQLAlchemy
    https://read.helloflask.com/c5-database#zai-cheng-xu-li-cao-zuo-shu-ju-ku
    https://dormousehole.readthedocs.io/en/latest/patterns/sqlalchemy.html
    https://www.cnblogs.com/fu-yong/p/9183951.html
"""
from model.dao.user import User
from flaskApp import db

class HelloDb :
    def insertOneUser(self, dictUser) :
        daoUser = User(**dictUser)
        db.session.add(daoUser)
        return db.session.commit()

    def queryUserByName(self, name) :
        daoUsers = User.query.filter_by(name = name).all()
        dictUsers = [daoUser.to_dict()   for daoUser in daoUsers ]
        return dictUsers





